package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

class zte {
   com.aspose.cells.a.f.zj a;
   zvh b;
   Workbook c;
   ContentTypePropertyCollection d;

   zte(Workbook var1, com.aspose.cells.a.f.zj var2) {
      this.a = var2;
      this.c = var1;
      this.d = var1.f;
   }

   zte(Workbook var1, zvh var2) {
      this.b = var2;
      this.c = var1;
      this.d = var1.f;
   }

   void a() throws Exception {
      if (this.b != null) {
         this.b();
      } else {
         this.c();
      }

   }

   void b() throws Exception {
      zane var1 = new zane();
      zane var2 = null;
      int var3 = 1;
      zng var4 = this.c.g;
      if (var4 != null && var4.getCount() > 0) {
         for(var3 = 1; var3 <= var4.getCount(); ++var3) {
            znf var5 = var4.a(var3 - 1);
            String var6 = zase.y(var3);
            var2 = new zane();
            var2.a("item", new com.aspose.cells.b.a.d.zh(var5.a));
            var2.a("Properties", new com.aspose.cells.b.a.d.zh(var5.b));
            var1.a(zase.y(var3), var2);
         }
      }

      if (this.d != null && this.d.getCount() != 0) {
         HashMap var10 = new HashMap();
         CustomDocumentPropertyCollection var11 = this.c.getCustomDocumentProperties();
         Iterator var7 = this.d.iterator();

         while(var7.hasNext()) {
            ContentTypeProperty var8 = (ContentTypeProperty)var7.next();
            ArrayList var9 = (ArrayList)var10.get(var8.c);
            if (var9 == null) {
               var9 = new ArrayList();
               var10.put(var8.c, var9);
            }

            com.aspose.cells.b.a.a.ze.a(var9, (Object)var8);
            if (var11.get(var8.getName()) == null) {
               var11.add(var8.getName(), var8.getValue());
            } else {
               var11.get(var8.getName()).setValue(var8.getValue());
            }
         }

         com.aspose.cells.b.a.d.zh var12 = new com.aspose.cells.b.a.d.zh();
         this.a((String)null, var10, var12);
         var12.b();
         com.aspose.cells.b.a.d.zh var13 = new com.aspose.cells.b.a.d.zh();
         this.b((String)null, var10, var13);
         var13.b();
         var2 = new zane();
         var2.a("item", var12);
         var2.a("Properties", var13);
         var1.a(zase.y(var3), var2);
         ++var3;
         var12 = new com.aspose.cells.b.a.d.zh();
         this.b((String)null, var12);
         var12.b();
         var13 = new com.aspose.cells.b.a.d.zh();
         this.c((String)null, var13);
         var13.b();
         var2 = new zane();
         var2.a("item", var12);
         var2.a("Properties", var13);
         var1.a(zase.y(var3), var2);
         this.b.a().a("MsoDataStore", var1);
      } else {
         if (var1.b() > 0) {
            this.b.a().a("MsoDataStore", var1);
         }

      }
   }

   void c() throws Exception {
      int var1 = 1;
      zng var2 = this.c.g;
      String var4;
      String var5;
      if (var2 != null && var2.getCount() > 0) {
         for(var1 = 1; var1 <= var2.getCount(); ++var1) {
            znf var3 = var2.a(var1 - 1);
            var4 = zase.y(var1);
            var5 = "customXml/item" + var4 + ".xml";
            zud.a(this.a, var5, var3.a, 0, var3.a.length);
            if (var3.b != null) {
               String var6 = "customXml/itemProps" + var4 + ".xml";
               zud.a(this.a, var6, var3.b, 0, var3.b.length);
               this.a("item" + var4 + ".xml", "itemProps" + var4 + ".xml");
            }
         }
      }

      if (this.d != null && this.d.getCount() != 0) {
         HashMap var7 = new HashMap();

         ContentTypeProperty var9;
         ArrayList var10;
         for(Iterator var8 = this.d.iterator(); var8.hasNext(); com.aspose.cells.b.a.a.ze.a(var10, (Object)var9)) {
            var9 = (ContentTypeProperty)var8.next();
            var10 = (ArrayList)var7.get(var9.c);
            if (var10 == null) {
               var10 = new ArrayList();
               var7.put(var9.c, var10);
            }
         }

         var4 = "item" + zase.y(var1) + ".xml";
         var5 = "itemProps" + zase.y(var1) + ".xml";
         this.a(var4, var7, (com.aspose.cells.b.a.d.zh)null);
         this.b(var5, var7, (com.aspose.cells.b.a.d.zh)null);
         this.a(var4, var5);
         ++var1;
         var4 = "item" + zase.y(var1) + ".xml";
         var5 = "itemProps" + zase.y(var1) + ".xml";
         this.a(var4);
         this.a(var5, var7);
         this.a(var4, var5);
         ++var1;
         var4 = "item" + zase.y(var1) + ".xml";
         var5 = "itemProps" + zase.y(var1) + ".xml";
         this.b(var4, (com.aspose.cells.b.a.d.zh)null);
         this.c(var5, (com.aspose.cells.b.a.d.zh)null);
         this.a(var4, var5);
      }
   }

   private void a(String var1) throws Exception {
      String var2 = "customXml/" + var1;
      zcfx var3 = zasr.a(var2, this.a, true);
      var3.b(true);
      var3.b("p:properties");
      var3.a("xmlns", "p", (String)null, "http://schemas.microsoft.com/office/2006/metadata/properties");
      var3.a("xmlns", "xsi", (String)null, "http://www.w3.org/2001/XMLSchema-instance");
      var3.b("documentManagement");

      for(int var4 = 0; var4 < this.d.getCount(); ++var4) {
         ContentTypeProperty var5 = this.d.get(var4);
         String var6 = var5.getName();
         String var7 = var5.getValue();
         var3.a((String)null, var6, true);
         var3.a("xmlns", (String)null, var5.c);
         var3.d(zase.a(var7));
         var3.a(true);
      }

      var3.b();
      var3.b();
      var3.d();
      var3.e();
   }

   private void a(String var1, HashMap var2) throws Exception {
      String var3 = "customXml/" + var1;
      zcfx var4 = zasr.a(var3, this.a, true);
      var4.b(true);
      var4.b("ds:datastoreItem");
      var4.a("ds:itemID", (String)null, "{BBB4F38B-0799-4886-B61C-8DBB46B47F73}");
      var4.a("xmlns", "ds", (String)null, "http://schemas.openxmlformats.org/officeDocument/2006/customXml");
      var4.c("ds:schemaRefs", (String)null);
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://schemas.microsoft.com/office/2006/metadata/properties");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://purl.org/dc/elements/1.1/");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://purl.org/dc/dcmitype/");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://schemas.microsoft.com/office/2006/documentManagement/types");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://purl.org/dc/terms/");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://schemas.microsoft.com/office/infopath/2007/PartnerControls");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://www.w3.org/XML/1998/namespace");
      var4.b();
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
      var4.b();
      Iterator var5 = var2.keySet().iterator();

      while(var5.hasNext()) {
         String var6 = (String)var5.next();
         var4.c("ds:schemaRef", (String)null);
         var4.a("ds:uri", var6);
         var4.b();
      }

      var4.b();
      var4.b();
      var4.d();
      var4.e();
   }

   private zcfx a(String var1, com.aspose.cells.b.a.d.zh var2) throws Exception {
      zcfx var3 = null;
      if (var2 == null) {
         var3 = zasr.a(var1, this.a, true);
      } else {
         var3 = zasr.a((com.aspose.cells.b.a.d.zm)var2, true);
      }

      return var3;
   }

   private void b(String var1, com.aspose.cells.b.a.d.zh var2) throws Exception {
      String var3 = "customXml/" + var1;
      zcfx var4 = this.a(var3, var2);
      var4.b(true);
      var4.b("FormTemplates");
      var4.a("xmlns", (String)null, "http://schemas.microsoft.com/sharepoint/v3/contenttype/forms");
      var4.b("Display", "DocumentLibraryForm");
      var4.b("Edit", "DocumentLibraryForm");
      var4.b("New", "DocumentLibraryForm");
      var4.b();
      var4.d();
      var4.e();
   }

   private void c(String var1, com.aspose.cells.b.a.d.zh var2) throws Exception {
      String var3 = "customXml/" + var1;
      zcfx var4 = this.a(var3, var2);
      var4.b(true);
      var4.b("ds:datastoreItem");
      var4.a("ds:itemID", (String)null, "{3847F8EF-8AAF-48C9-9DFE-A66AC49D528B}");
      var4.a("xmlns", "ds", (String)null, "http://schemas.openxmlformats.org/officeDocument/2006/customXml");
      var4.c("ds:schemaRefs", (String)null);
      var4.c("ds:schemaRef", (String)null);
      var4.a("ds:uri", "http://schemas.microsoft.com/sharepoint/v3/contenttype/forms");
      var4.b();
      var4.b();
      var4.b();
      var4.d();
      var4.e();
   }

   private void a(String var1, HashMap var2, com.aspose.cells.b.a.d.zh var3) throws Exception {
      String var4 = "customXml/" + var1;
      zcfx var5 = this.a(var4, var3);
      var5.b(true);
      var5.b("ct:contentTypeSchema");
      var5.a("ct:_", (String)null, "");
      var5.a("ma:_", (String)null, "");
      var5.a("ma:contentTypeName", (String)null, "Document");
      var5.a("ma:contentTypeID", (String)null, "0x01010002CD4CE788C0924AAB9A9AF8274C3BA0");
      var5.a("ma:contentTypeVersion", (String)null, "4");
      var5.a("ma:contentTypeDescription", (String)null, "Create a new document.");
      var5.a("ma:contentTypeScope", (String)null, "");
      var5.a("ma:versionID", (String)null, "273ab99c845a0ab368c691b7cbc8d5c9");
      var5.a("xmlns", "ct", (String)null, "http://schemas.microsoft.com/office/2006/metadata/contentType");
      var5.a("xmlns", "ma", (String)null, "http://schemas.microsoft.com/office/2006/metadata/properties/metaAttributes");
      var5.c("xsd:schema", (String)null);
      var5.a("targetNamespace", "http://schemas.microsoft.com/office/2006/metadata/properties");
      var5.a("ma:root", "true");
      var5.a("ma:fieldsID", "cc735bd373cf9519d82bcfd02363e949");
      var5.a("ns1:_", "");
      var5.a("xmlns", "xsd", (String)null, "http://www.w3.org/2001/XMLSchema");
      var5.a("xmlns", "xs", (String)null, "http://www.w3.org/2001/XMLSchema");
      var5.a("xmlns", "p", (String)null, "http://schemas.microsoft.com/office/2006/metadata/properties");
      Set var6 = var2.keySet();
      int var7 = 1;

      Iterator var8;
      String var9;
      for(var8 = var6.iterator(); var8.hasNext(); ++var7) {
         var9 = (String)var8.next();
         var5.a("xmlns", "ns" + var7, (String)null, var9);
      }

      var8 = var6.iterator();

      while(var8.hasNext()) {
         var9 = (String)var8.next();
         var5.c("xsd:import", (String)null);
         var5.a("namespace", var9);
         var5.b();
      }

      var5.c("xsd:element", (String)null);
      var5.a("name", "properties");
      var5.c("xsd:complexType", (String)null);
      var5.c("xsd:sequence", (String)null);
      var5.c("xsd:element", (String)null);
      var5.a("name", "documentManagement");
      var5.c("xsd:complexType", (String)null);
      var5.c("xsd:all", (String)null);
      var7 = 1;

      ArrayList var10;
      Iterator var11;
      ContentTypeProperty var12;
      for(var8 = var6.iterator(); var8.hasNext(); ++var7) {
         var9 = (String)var8.next();
         var10 = (ArrayList)var2.get(var9);
         var11 = var10.iterator();

         while(var11.hasNext()) {
            var12 = (ContentTypeProperty)var11.next();
            var5.c("xsd:element", (String)null);
            var5.a("ref", "ns" + var7 + ":" + var12.getName());
            var5.a("minOccurs", "0");
            var5.b();
         }
      }

      var5.b();
      var5.b();
      var5.b();
      var5.b();
      var5.b();
      var5.b();
      var5.b();
      var8 = var6.iterator();

      while(var8.hasNext()) {
         var9 = (String)var8.next();
         var5.c("xsd:schema", (String)null);
         var5.a("targetNamespace", var9);
         var5.a("elementFormDefault", "qualified");
         var5.a("xmlns", "xsd", (String)null, "http://www.w3.org/2001/XMLSchema");
         var5.a("xmlns", "xs", (String)null, "http://www.w3.org/2001/XMLSchema");
         var5.a("xmlns", "dms", (String)null, "http://schemas.microsoft.com/office/2006/documentManagement/types");
         var5.a("xmlns", "pc", (String)null, "http://schemas.microsoft.com/office/infopath/2007/PartnerControls");
         var5.c("xsd:import", (String)null);
         var5.a("namespace", "http://schemas.microsoft.com/office/2006/documentManagement/types");
         var5.b();
         var5.c("xsd:import", (String)null);
         var5.a("namespace", "http://schemas.microsoft.com/office/infopath/2007/PartnerControls");
         var5.b();
         var10 = (ArrayList)var2.get(var9);

         for(var11 = var10.iterator(); var11.hasNext(); var5.b()) {
            var12 = (ContentTypeProperty)var11.next();
            var5.c("xsd:element", (String)null);
            var5.a("name", var12.getName());
            var5.a("ma:index", zase.y(var12.b));
            var5.a("ma:displayName", var12.g == null ? var12.getName() : var12.g);
            if (var12.i != null) {
               var5.a("ma:default", var12.i);
            }

            if (var12.e != null) {
               var5.a("ma:format", var12.e);
            }

            var5.a("ma:internalName", var12.h == null ? var12.getName() : var12.h);
            if (var12.j != null) {
               Iterator var13 = var12.j.keySet().iterator();

               while(var13.hasNext()) {
                  String var14 = (String)var13.next();
                  var5.a(var14, (String)((String)var12.j.get(var14)));
               }
            }

            if (var12.l != null) {
               var5.c("xsd:complexType", (String)null);
               var5.d(var12.l);
               var5.b();
            } else {
               var5.c("xsd:simpleType", (String)null);
               var5.c("xsd:restriction", (String)null);
               if (var12.d != null) {
                  var5.a("base", var12.d);
               } else {
                  var5.a("base", "dms:Text");
               }

               for(int var15 = 0; var15 < var12.f.size(); ++var15) {
                  var5.c("xsd:enumeration ", (String)null);
                  var5.a("value", (String)var12.f.get(var15));
                  var5.b();
               }

               var5.b();
               var5.b();
            }
         }

         var5.b();
      }

      var5.c("xsd:schema", (String)null);
      var5.a("targetNamespace", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
      var5.a("elementFormDefault", "qualified");
      var5.a("attributeFormDefault", "unqualified");
      var5.a("blockDefault", "#all");
      var5.a("xmlns", (String)null, "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
      var5.a("xmlns", "xsd", (String)null, "http://www.w3.org/2001/XMLSchema");
      var5.a("xmlns", "xsi", (String)null, "http://www.w3.org/2001/XMLSchema-instance");
      var5.a("xmlns", "dc", (String)null, "http://purl.org/dc/elements/1.1/");
      var5.a("xmlns", "dcterms", (String)null, "http://purl.org/dc/terms/");
      var5.a("xmlns", "odoc", (String)null, "http://schemas.microsoft.com/internal/obd");
      var5.c("xsd:import", (String)null);
      var5.a("namespace", "http://purl.org/dc/elements/1.1/");
      var5.a("schemaLocation", "http://dublincore.org/schemas/xmls/qdc/2003/04/02/dc.xsd");
      var5.b();
      var5.c("xsd:import", (String)null);
      var5.a("namespace", "http://purl.org/dc/terms/");
      var5.a("schemaLocation", "http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "coreProperties");
      var5.a("type", "CT_coreProperties");
      var5.b();
      var5.c("xsd:complexType ", (String)null);
      var5.a("name", "CT_coreProperties");
      var5.c("xsd:all ", (String)null);
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dc:creator");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dcterms:created");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dc:identifier");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "contentType");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.a("ma:index", "0");
      var5.a("ma:displayName", "Content Type");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dc:title");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dc:subject");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dc:description");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "keywords");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dc:language");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "category");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "version");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "revision");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.c("xsd:annotation", (String)null);
      var5.b("xsd:documentation", "This value indicates the number of saves or revisions. The application is responsible for updating this value after each revision.");
      var5.b();
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "lastModifiedBy");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("ref", "dcterms:modified");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.b();
      var5.c("xsd:element", (String)null);
      var5.a("name", "contentStatus");
      var5.a("minOccurs", "0");
      var5.a("maxOccurs", "1");
      var5.a("type", "xsd:string");
      var5.b();
      var5.b();
      var5.b();
      var5.b();
      var5.b();
      var5.d();
      var5.e();
   }

   private void b(String var1, HashMap var2, com.aspose.cells.b.a.d.zh var3) throws Exception {
      String var4 = "customXml/" + var1;
      zcfx var5 = this.a(var4, var3);
      var5.b(true);
      var5.b("ds:datastoreItem");
      var5.a("ds:itemID", (String)null, "{CFA01330-14A1-4347-A117-D4993E0979C9}");
      var5.a("xmlns", "ds", (String)null, "http://schemas.openxmlformats.org/officeDocument/2006/customXml");
      var5.c("ds:schemaRefs", (String)null);
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.microsoft.com/office/2006/metadata/contentType");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.microsoft.com/office/2006/metadata/properties/metaAttributes");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://www.w3.org/2001/XMLSchema");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.microsoft.com/office/2006/metadata/properties");
      var5.b();
      Iterator var6 = var2.keySet().iterator();

      while(var6.hasNext()) {
         String var7 = (String)var6.next();
         var5.c("ds:schemaRef", (String)null);
         var5.a("ds:uri", var7);
         var5.b();
      }

      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.microsoft.com/office/2006/documentManagement/types");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.microsoft.com/office/infopath/2007/PartnerControls");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://purl.org/dc/elements/1.1/");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://purl.org/dc/terms/");
      var5.b();
      var5.c("ds:schemaRef", (String)null);
      var5.a("ds:uri", "http://schemas.microsoft.com/internal/obd");
      var5.b();
      var5.b();
      var5.b();
      var5.d();
      var5.e();
   }

   private void a(String var1, String var2) throws Exception {
      ArrayList var3 = new ArrayList();
      zqe var4 = new zqe();
      var4.c = "rId1";
      var4.d = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";
      var4.e = var2;
      com.aspose.cells.b.a.a.ze.a(var3, (Object)var4);
      String var5 = "customXml/_rels/" + var1 + ".rels";
      zcfx var6 = zasr.a(var5, this.a, true);
      ztt.a(var6, var3);
      var6.e();
   }
}
